<template>
	<div class="loginpage">
		<div class="login-main">
			<div class="logo">
				<img src="../assets/img/logo2.png" alt="" srcset="">
			</div>
			<div class="login-content">
				<img src="../assets/img/login-bg.png" alt="" srcset="">
				<div class="login-box">
					<h1>Sign Up</h1>
					<p class="login-item">
						<input type="text" placeholder="请输入账号" v-model="name" >
					</p>
					<p class="login-item">
						<input type="password" @keyup.enter="keydown()" placeholder="请输入密码" v-model="pwd">
					</p>
					<button @click="_Login()">登录</button>
				</div>
			</div>
		</div>
	</div>
</template>
<script>
	import {Login} from '@/utils/api'
	export default {
		data(){
			return {
				name:'',
				pwd:''
			}
		},
		methods:{
			async _Login(){
				let {data} = await Login({UserName:this.name,Pwd:this.pwd})
				localStorage.setItem("adminToken",data.Token)
				localStorage.setItem("UserName",data.UserName)
				this.$store.commit('SET_ROLE',data.Role)
				this.$router.push({path:'/'})
			},
			keydown(e) {
				this._Login();
			}
		}
	}
</script>
<style lang="scss">
	.loginpage {
		width: 100%;
		height: 100%;
		background: linear-gradient(225deg, #99A6FF 0%, #6674FA 100%, #B0B7FF 100%);
		display: flex;
		align-items: center;
		justify-content: center;
		.login-main{
			width: 1200px;
			background: #fff;
			border-radius: 20px;
			border: 4px solid #4C52FF;
			padding: 30px 0 0;
			box-sizing: border-box;
			overflow: hidden;
		}
		.login-content{
			display: flex;
			align-items: center;
			justify-content: space-between;
		}
		.logo{
			display: flex;
			justify-content: center;
		}
		.login-box{
			flex: 1;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			margin-top: -100px;
			h1{
				color: #485CFF;
				font-size: 34px;
				margin-bottom: 40px;
			}
			.login-item{
				border: 2px solid #485CFF;
				height: 60px;
				border-radius: 60px;
				display: flex;
				align-items: center;
				padding: 0 20px;
				width: 450px;
				box-sizing: border-box;
				background: #fff;
				margin-bottom: 20px;
				input{
					flex: 1;
					border: none;
					outline: none;
					font-size: 16px;
				}
			}
			button{
				height: 60px;
				width: 450px;
				background: linear-gradient(90deg, #8082ED 0%, #485CFF 100%);
				border-radius: 60px;
				line-height: 60px;
				color: #fff;
				box-sizing: border-box;
				font-size: 20px;
				&:active{
					opacity: 0.8;
				}
			}
		}
	}
</style>